package com.wkhyapp.lm.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wkhyapp.lm.R;
import com.wkhyapp.lm.constant.Constant;
import com.wkhyapp.lm.http.vo.Fans;
import com.wkhyapp.lm.utils.ImageLoadUtil;

import java.util.List;

/**
 * Created by Administrator on 2021-10-6.
 */

public class GZAdapter extends BaseQuickAdapter<Fans, BaseViewHolder> {

    public GZAdapter.callBack mCallBack;

    public GZAdapter(int layoutResId, List<Fans> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final Fans item) {
        ImageView imageView = helper.getView(R.id.gz_head_iv);
        helper.setText(R.id.name_tv,item.getNickname());
        helper.setText(R.id.mark_tv,item.getRemark());
        if(item.getHeadImg().startsWith("http")){
            ImageLoadUtil.setCirlcleImage_Normal(mContext,item.getHeadImg(),50,imageView);
        }else{
            ImageLoadUtil.setCirlcleImage_Normal(mContext, Constant.DEF_HEAD,50,imageView);
        }

        ImageView lv_iv = helper.getView(R.id.lv_iv2);

        if("2".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_hj,lv_iv);
        }else if("3".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zs,lv_iv);
        }else if("4".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz,lv_iv);
        }else if("5".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz1,lv_iv);
        }else if("6".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz2,lv_iv);
        }else if("7".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz3,lv_iv);
        }
        else if("8".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz4,lv_iv);
        }
        else if("9".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz5,lv_iv);
        }
        else if("10".equals(item.getLevelId())){
            lv_iv.setVisibility(View.VISIBLE);
            ImageLoadUtil.setImage_Normal(mContext,R.drawable.lv_zz6,lv_iv);
        }
        else{
            lv_iv.setVisibility(View.GONE);
        }

        RelativeLayout fans_rl = helper.getView(R.id.gz_rl);
        fans_rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.action(item);
            }
        });
    }


    public void  setCallBack(GZAdapter.callBack callBack){
        this.mCallBack = callBack;
    }


    public interface  callBack{
        void action(Fans item);
    }
}
